package com.leyantech.ecp.agenx.common.redis;

import com.leyantech.ecp.agenx.common.config.Constants;
import com.leyantech.utility.constructs.Constructs;

/**
 * @author eahau, {@literal <eahau@foxmail.com>}
 * @date 2022-11-17.
 */
public class RedisKeyUtils {

  private RedisKeyUtils() {
  }

  /**
   * namespace, 确保测试环境可以公用一个 redis.
   */
  static final String PREFIX = Constants.ENV.equalsIgnoreCase("sth")
      ? Constructs.getAppNameOrDefault() + ":"
      : "";

  public static String keyOf(String... keys) {
    return PREFIX + String.join(".", keys);
  }

  public static String keyOfAssistantConnectLock(String storeId, String assistantId) {
    return keyOf("connector", "lock", storeId, assistantId);
  }

}
